/*
 * TransferableObject.java
 *
 * Created on August 30, 2007, 8:13 PM
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */

package com.afaker.rss.gui.dnd;

import java.awt.datatransfer.DataFlavor;
import java.awt.datatransfer.Transferable;
import java.awt.datatransfer.UnsupportedFlavorException;
import java.io.IOException;

/**
 *
 * @author bruce
 */
public class TransferableObject implements Transferable{
    private Object object;
    public static DataFlavor localObjectFlavor;
    public static DataFlavor  javaRemoteObjectMimeType;
    public static DataFlavor  javaSerializedObjectMimeType ;
    static {
        try {            
            localObjectFlavor = new DataFlavor(DataFlavor.javaJVMLocalObjectMimeType);
            javaRemoteObjectMimeType = new DataFlavor(DataFlavor.javaRemoteObjectMimeType);
        } catch (ClassNotFoundException ex) {
            ex.printStackTrace();
        }
    }
    static DataFlavor[] supportedFlavor = {localObjectFlavor,DataFlavor.javaFileListFlavor,javaRemoteObjectMimeType};
    /** Creates a new instance of TransferableObject */
    public TransferableObject(Object obj) {
        object = obj;
    }
    
    public DataFlavor[] getTransferDataFlavors() {
        return supportedFlavor;
    }
    
    public boolean isDataFlavorSupported(DataFlavor flavor) {
        return true;
    }
    
    public Object getTransferData(DataFlavor flavor) throws UnsupportedFlavorException, IOException {
        return object;
       /*if(isDataFlavorSupported(flavor))
            return object;
        else
            throw new UnsupportedFlavorException(flavor);*/
    }
    
}
